from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response
from django.http import HttpResponse
from afms.activity import models


@login_required
def profile(request):
    groups_man  = models.GroupShip.objects.filter(member=request.user, is_manager=True)
    groups_join = models.GroupShip.objects.filter(member=request.user, is_manager=False)
    gj_admins   = []
    for g in groups_join:
        admins = [ gs.member for gs in models.GroupShip.objects.filter(group=g, is_manager=True) ]
        gj_admins.append(admins)
    ctx = {'user': request.user, 'groups_man': groups_man, 'groups_join': groups_join, 'gj_admins': gj_admins}
    return render_to_response('profile.html', ctx)


@login_required
def group_detail(request):
    return HttpResponse("group_detail: " + request.GET['gid'])